<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/15 0015
 * Time: 下午 3:53
 */
namespace app\article\validate;
use think\Db;
use think\Validate;

class ValidateFun extends Validate{
    public function __construct(array $rules = [], array $message = [], array $field = [])
    {
        parent::__construct($rules, $message, $field);
    }
    #文章id是否存在
    public function checkId($v ='')
    {
        $info = Db::name('compose')->where(['del'=>1,'userid'=>$v])->select();
        if ($info){
            return true;
        }else{
            return false;
        }
    }
    #回复评论id是否存在
    public function checkReplyId($v =''){
        $info = Db::name('reply')->where(['del'=>1,'id'=>$v])->select();
        if ($info){
            return true;
        }else{
            return false;
        }
    }
    #评论id是否存在
    public function checkCmId($v=''){
        $info = Db::name('comment')->where(['del'=>1,'id'=>$v])->select();
        if ($info){
            return true;
        }else{
            return false;
        }
    }

    #用户id是否存在
    public function checkUserID($v=''){
        $info = Db::name('member')->where(['del'=>1,'id'=>$v])->find();
        if ($info){
            return true;
        }else{
            return false;
        }
    }
}